import Vue from 'vue'
import Util from '@/core/js/util.js'
import Const from '@/core/js/const.js'
function timeFormat(timestamp, format) {
  if (!timestamp) {
    return '-'
  }

  if (!format) {
    format = 'Y-m-d H:i:s'
  }
  return Util.date(format, timestamp / 1000)
}

function moneyFormat (money) {
  return money % 100 > 0 ? (money / 100.0).toFixed(2) : money / 100
}

const _filters = {
  timeFormat: timeFormat,
  moneyFormat: moneyFormat
}

export default () => {
  Object.keys(_filters).forEach(key => {
    Vue.filter(key, _filters[key])
  })
}
